package com.yunmaozj.tools.lock.service;

import com.yunmaozj.tools.lock.annotations.DistributedLock;
import com.yunmaozj.tools.lock.domain.User;
import com.yunmaozj.tools.lock.interceptor.BusinessIdGenerator;

import java.lang.reflect.Method;

/**
 * @author 钟明宏
 * @version V1.0
 * @date 2021-08-23 20:47
 **/
public interface UserService {


    @DistributedLock(businessIdGenerator = UserBusinessIdGenerator.class)
    User getUserById(int userid);

    class UserBusinessIdGenerator implements BusinessIdGenerator {
        @Override
        public String getBusinessId(Method method, Class<?> targetClass, Object[] params) {
            return targetClass.getName()+"#"+method.getName()+"-"+params[0];
        }
    }
}
